﻿$(document).ready(function(){
    $("a.remove").each(function(i){
        $(this).one("click",function(){
            var id = $("a.remove:eq("+i+")").closest("tr").find("td:eq(0)").text();
            $.getJSON("ShoppingCartServices.ashx", {"id": id}, function(json){
                $("a.remove:eq("+i+")").closest("tr").remove();
            });
        });
    });
    
    $("#clean").bind("click",function(){
        $.ajax({
            type: "POST",
            dataType:"json",
            contentType:"application/json",
            processData: false,
            url: "ShopService.asmx/ClearCart",
            complete: function(msg){
                $("table.goodsOrder tr").remove();
                $("table.goodsOrder tbody").append("<tr><td>您的购物车中还没有任何商品。</td></tr>");
            }
        });
    });
});
